home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / STGDOC.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  5KB  |  179 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1993, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. //----------------------------------------------------------------------------
  8. #if !defined(OWL_STGDOC_H)
  9. #define OWL_STGDOC_H
  10.  
  11. #if !defined(OWL_DOCVIEW_H)
  12. # include <owl/docview.h>
  13. #endif
  14. #if !defined(__IOSTREAM_H)
  15. # include <iostream.h>
  16. #endif
  17.  
  18. //
  19. // Forward reference OLE interface without including headers
  20. //
  21. #if defined(BI_PLAT_WIN16)
  22.   class __huge IStorage;
  23.   class __huge IStream;
  24. #else
  25.   class IStorage;
  26.   class IStream;
  27. #endif
  28.  
  29. #if defined(BI_NAMESPACE)
  30. namespace OWL {
  31. #endif
  32.  
  33. // Generic definitions/compiler options (eg. alignment) preceeding the 
  34. // definition of classes
  35. #include <services/preclass.h>
  36.  
  37. //
  38. // class TStorageDocument
  39. // ~~~~~ ~~~~~~~~~~~~~~~~
  40. class _USERCLASS TStorageDocument : public TDocument {
  41.   public:
  42.     enum TStgDocProp {
  43.       PrevProperty = TDocument::NextProperty-1,
  44.       CreateTime,        // FILETIME
  45.       ModifyTime,        // FILETIME
  46.       AccessTime,        // FILETIME
  47.       StorageSize,       // ulong
  48.       IStorageInstance,  // IStorage*
  49.       NextProperty,
  50.     };
  51.     TStorageDocument(TDocument* parent = 0);
  52.    ~TStorageDocument();
  53.     virtual bool  ReleaseDoc();
  54.  
  55.     // Implement virtual methods of TDocument
  56.     //
  57.     TInStream*    InStream(int omode, const char far* strmId=0);
  58.     TOutStream*   OutStream(int omode, const char far* strmId=0);
  59.     bool          Open(int omode, const char far* stgId);
  60.     bool          Close();
  61.     bool          Commit(bool force = false);
  62.     bool          CommitTransactedStorage();
  63.     bool          Revert(bool clear = false);
  64.     bool          SetDocPath(const char far* path);
  65.     bool          IsOpen();
  66.  
  67.     int           FindProperty(const char far* name);  // return index
  68.     int           PropertyFlags(int index);
  69.     const char*   PropertyName(int index);
  70.     int           PropertyCount();
  71.     int           GetProperty(int index, void far* dest, int textlen=0);
  72.     bool          SetProperty(int index, const void far* src);
  73.  
  74.     // Additional methods for obtaining or changing the IStorage
  75.     //
  76.     virtual bool  SetStorage(IStorage* stg, bool remember = true);  // Set a new IStorage
  77.     virtual bool  RestoreStorage();
  78.     virtual IStorage* GetNewStorage();
  79.     IStorage*     GetStorage();
  80.  
  81.     virtual bool  OpenHandle(int omode, HANDLE hGlobal); // open on global memory
  82.     virtual bool  SetHandle(int omode, HANDLE hGlobal, bool create = false, bool remember = false);
  83.     virtual bool  GetHandle(HGLOBAL* handle);
  84.  
  85.   protected:
  86.     int           GetThisOpen();
  87.     IStorage*     GetOrgStorageI();
  88.     ILockBytes*   GetLockBytes();
  89.  
  90.   protected_data:
  91.     int           ThisOpen;    // Actual mode bits used for opening storage
  92.     IStorage*     StorageI;    // Current IStorage instance, 0 if not open
  93.     IStorage*     OrgStorageI; // Pointer to original IStorage interface
  94.     ILockBytes*   LockBytes;   // Pointer to ILockBytes used, if any
  95.  
  96.   private:
  97.     bool          CanRelease;  // Can we release the IStorage?
  98.     int           OpenCount;
  99.  
  100.     void          DetachStream(TStream& strm); // Override TDocument virtual
  101.  
  102.   DECLARE_STREAMABLE(_OWLCLASS, TStorageDocument,1);
  103.   friend class _OWLCLASS_RTL TStorageInStream;
  104.   friend class _OWLCLASS_RTL TStorageOutStream;
  105. };
  106.  
  107. // Generic definitions/compiler options (eg. alignment) following the 
  108. // definition of classes
  109. #include <services/posclass.h>
  110.  
  111. #if defined(BI_NAMESPACE)
  112. } // namespace OWL
  113. #endif
  114.  
  115. // --------------------------------------------------------------------------
  116. // Inline implementations
  117.  
  118. //
  119. // Construct a default Storage document object
  120. //
  121. inline TStorageDocument::TStorageDocument(TDocument* parent)
  122. :
  123.   TDocument(parent), StorageI(0), OpenCount(0), CanRelease(false),
  124.   OrgStorageI(0), LockBytes(0)
  125. {
  126. }
  127.  
  128. //
  129. // Return 'true' if the storage document object has opened an OLE storage.
  130. // Return 'false' otherwise.
  131. //
  132. inline bool TStorageDocument::IsOpen() {
  133.   return (StorageI != 0);
  134. }
  135.  
  136. //
  137. // Return the number of properties supported by the storage document object.
  138. // NOTE: The number includes the inherited properties of the storage 
  139. //       document object.
  140. //
  141. inline int TStorageDocument::PropertyCount() {
  142.   return NextProperty - 1;
  143. }
  144.  
  145. //
  146. // Return the IStorage interface pointer currently associated with the 
  147. // storage document object. Returns 0 if no storage is currently opened.
  148. //
  149. inline IStorage* TStorageDocument::GetStorage() {
  150.   return StorageI;
  151. }
  152.  
  153. //
  154. // Return the mode bits used to open the storage currently associated with 
  155. // this storage object.
  156. //
  157. inline int TStorageDocument::GetThisOpen() {
  158.   return ThisOpen;
  159. }
  160.  
  161. //
  162. // Return a pointer to the original IStorage interface associated with this
  163. // storage document object.
  164. //
  165. inline IStorage* TStorageDocument::GetOrgStorageI() {
  166.   return OrgStorageI;
  167. }
  168.  
  169. //
  170. // Return a pointer to the ILockBytes interface currently being used by this
  171. // storage document object. Return 0 if no ILockBytes interface is in use.
  172. //
  173. inline ILockBytes* TStorageDocument::GetLockBytes() {
  174.   return LockBytes;
  175. }
  176.  
  177.  
  178. #endif  // OWL_STGDOC_H
  179.